package com.fyzk.activity.chongzhi;

import android.annotation.SuppressLint;
import android.content.Intent;

import com.fyzk.activity.app.AppToast;
import com.tyjc.lottery.R;

public class CZ_YL_JAR extends CZ_BaseActivity {
	

	private final String R_SUCCESS = "success";
	private final String R_FAIL = "fail";
	private final String R_CANCEL = "cancel";

	public static final int PLUGIN_VALID = 0;
    public static final int PLUGIN_NOT_INSTALLED = -1;
    public static final int PLUGIN_NEED_UPGRADE = 2;
	
    /*****************************************************************
     * mMode参数解释： "00" - 启动银联正式环境 "01" - 连接银联测试环境
     *****************************************************************/
	String mMode = "00";
	
	@SuppressWarnings("deprecation")
	@SuppressLint("SetJavaScriptEnabled")
	public void recharge() {
//		int ret = UPPayAssistEx.startPay(this,null, null, mObj_response.result, mMode);
//		if (ret == UPPayAssistEx.PLUGIN_NOT_FOUND) {
//			UPPayAssistEx.installUPPayPlugin(this);
//		}
//		UPPayAssistEx.startPayByJAR(this, PayActivity.class, null, null,
//				mObj_response.result, mMode);
//		int ret = UPPayAssistEx.startPay(this, null, null, mObj_response.result, mMode);
//        if (ret == PLUGIN_NEED_UPGRADE || ret == PLUGIN_NOT_INSTALLED) {
//            // 需要重新安装控件
////            Log.e(LOG_TAG, " plugin not found or need upgrade!!!");
//
//            AlertDialog.Builder builder = new AlertDialog.Builder(this);
//            builder.setTitle("提示");
//            builder.setMessage("完成购买需要安装银联支付控件，是否安装？");
//
//            builder.setNeutralButton("确定",
//                    new DialogInterface.OnClickListener() {
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//                            UPPayAssistEx.installUPPayPlugin(CZ_YL_JAR.this);
//                            dialog.dismiss();
//                        }
//                    });
//
//            builder.setPositiveButton("取消",
//                    new DialogInterface.OnClickListener() {
//
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//                            dialog.dismiss();
//                        }
//                    });
//            builder.create().show();

//        }
//        Log.e(LOG_TAG, "" + ret);
	}
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (data == null) {
			return;
		}
		String str = data.getExtras().getString("pay_result");
		if (str.equalsIgnoreCase(R_SUCCESS)) {
			AppToast.getToast().show(" 支付成功！ ");
			finish();
		} else if (str.equalsIgnoreCase(R_FAIL)) {
			AppToast.getToast().show(" 支付失败！ ");
		} else if (str.equalsIgnoreCase(R_CANCEL)) {
			AppToast.getToast().show(" 充值行为被打断，请重新充值！ ");
		}
	}

	
	@Override
	public void initViewData() {
		super.initViewData();
		zfb_title_rl.setCenterText("银联充值");
		tishi1.setText(R.string.yl_tishi1);
		tishi2.setText(R.string.yl_tishi2);
	}

	@Override
	public String initRechargeType() {
		return RECHARE_YL+"";
	}

}
